package org.timemachine.resource;

import java.io.InputStream;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

public class Resources {
	private ResourceBundle bundle;

	private static Resources instance;

	public static Resources getInstance(String propName) {
		instance = new Resources(propName);
		return instance;
	}

	public static void setInstance(Resources instance) {
		Resources.instance = instance;
	}

	public Resources(String propName) {
		InputStream file = this.getClass().getClassLoader().getResourceAsStream("/META-INF/" + propName + ".properties");
		try {
			bundle = new PropertyResourceBundle(file);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	public String getProperty(String key) {
		return bundle.getString(key);
	}

}
